package com.dhnsoft.shortLink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dhnsoft.shortLink.project.dao.entity.LinkDeviceStatsDO;
import com.dhnsoft.shortLink.project.dto.req.ShortLinkStatsReqDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface LinkDeviceStatsMapper extends BaseMapper<LinkDeviceStatsDO> {
    @Insert("insert into t_link_device_stats(full_short_url,gid,date,cnt,device,create_time,update_time,del_flag)" +
            "values(#{linkDeviceStatsDO.fullShortUrl},#{linkDeviceStatsDO.gid},#{linkDeviceStatsDO.date},#{linkDeviceStatsDO.cnt}" +
            ",#{linkDeviceStatsDO.device},now(),now(),0)ON DUPLICATE KEY UPDATE cnt=cnt+#{linkDeviceStatsDO.cnt}," +
            "update_time=now()")
    void linkDeviceStatsDO(@Param("linkDeviceStatsDO") LinkDeviceStatsDO linkDeviceStatsDO);

    List<LinkDeviceStatsDO> listDeviceStatsByShortLink(@Param("param") ShortLinkStatsReqDTO requestParam);
}

